<?php
session_start();
require('conn.php');
require('functions.php');
$tjd=$_COOKIE['tjd'];
//短信验证码
$_SESSION['yzm1']=rand(1111,9999);
//全站访问
if($config['fangwen']==4){
	exit('网站正在更新');
}	
if($_SESSION['login']==1){
	_location("ucenter.php",301);
	exit;
}

$ip=GetIP();

//地区限制
if($config['area']!=='全国'){
	require('ipclass.php');
	$iplocation = new IpLocation();   
	$location = $iplocation->getlocation($ip);   
	$country=to_utf8($location['country']);
	$config_country=$config['area'].$config['city'];
	$country2=str_replace('地区','',$config_country);
	if($country!==$country2){
		exit('当前城市非注册地区，禁止注册');
	}
}


//注册推荐人
if(is_numeric($tjd)){
	$tj_id=$tjd;
}else{
	$tj_id=guolv(trim($_POST['tj_id']));
}
$nick='';
if(is_numeric($tj_id)){
	$nick="bbb";
	$row_tj=$mysql->query("select * from `userdata` where `id` in({$tj_id})");
	if(!$row_tj){
		$tj_id=0;
	}else{
		
		}
}else{
	$tj_id=0;
}



if($_POST){
	$phone=guolv(trim($_POST['username']));
	$pass=guolv(trim($_POST['password']));
	// $code=guolv(trim($_POST['code']));
	$yzm=guolv(trim($_POST['yzm']));
	//$yzm1 = substr($phone,3,4);
	
	if($config['openreg']==0){
		echo "<script>alert('注册关闭，请联系我们');location.href='reg.php'</script>";
		exit;		
	}
	if($config['ipreg2']==1){
		$row_ip=$mysql->query("select * from `userdata` where `ip`='{$ip}' order by `id` limit 1");//获取相同ip
		if($row_ip){
			echo "<script>alert('为防止同一人注册多个号,禁止同一ip重复注册!');location.href='reg.php'</script>";
			exit;			
		}	
	}	
	if(is_phone($phone)==false){
		echo "<script>alert('请输入正确的手机号');location.href='reg.php'</script>";
		exit;
	}

	if($pass==''){
		echo "<script>alert('请输入密码');location.href='reg.php'</script>";
		exit;		
	}
	
	if($config['yunpian']!==''){
		if($yzm==!$_SESSION['yzm1']){
		echo "<script>alert('验证码错误');location.href='reg.php'</script>";
		exit;		
		}
	}

	$row=$mysql->query("select * from `userdata` where `phone`='{$phone}' limit 1");
	if(!$row){
		$arr=array(
			//'id'=>null,
			'tj_id'=>$tj_id,
			'phone'=>$phone,
			'pass'=>$pass,
			'money'=>$song,
			'wx'=>'',
			'realname'=>'',
			'alipay'=>'',
			'wgateid'=>'',
			'ip'=>$ip,
			'kou'=>100,
			'day'=>date("Y-m-d",time()),
			'time'=>time(),
		);
		$value=arr2s($arr);
		$mysql->query("insert into `userdata` {$value}");
		//$mysql->query("INSERT INTO `userdata` (`id`, `tj_id`, `phone`, `pass`, `money`, `wx`, `realname`, `alipay`, `wgateid`, `ip`, `kou`, `day`, `time`) VALUES (NULL, '{$tj_id}', '{$phone}', '{$pass}', '{$song}', '', '', '', '', '{$ip}', '100', '{$day}', '{$time}');");	
		$id=mysql_insert_id();
		if($id!==0){
			//师傅获得多少奖励
			if($config['reg_yzr1']!==0 && $tj_id!==0){
				$mysql->execute("update `userdata` set `money`=`money`+'{$config['reg_yzr1']}' where `id`='{$tj_id}'");
				//写入状态
					$arr_reg_yzr1=array(
						'uid'=>$tj_id,
						'aid'=>'',
						'title'=>"新收徒弟ID：{$id}发放奖励",
						'long'=>'#',
						'money'=>$config['reg_yzr1'],
						'ip'=>$ip,
						'day'=>$day,
						'time'=>time(),
					);
				$value_reg_yzr1=arr2s($arr_reg_yzr1);
				$mysql->query("insert into `refererdata` {$value_reg_yzr1}");
			}
			echo "<script>alert('注册成功！请重新登录');location.href='login.php'</script>";
			exit;
		}else{
			echo "<script>alert('注册失败');location.href='reg.php'</script>";
			exit;			
		}
	}else{
		echo "<script>alert('手机号已经被占用');location.href='reg.php'</script>";
		exit;		
	}
}



$uid=$_GET['uid'];
$nick="";
if(is_numeric($uid)){

	$row=$mysql->query("select * from `userdata` where `id` ={$uid}");
	if($row){
		  
		 $nick=$row[0]["nick"];
	} 
 
}

?>
<!doctype html>
<html>
<meta charset="utf-8">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>注册 - <?php echo $config['sitename']?></title>
<meta name="keywords" content="<?php echo $config['sitename']?>,用户注册。" />
<meta name="description" content="<?php echo $config['sitename']?>用户注册。">

<link href="Css1/base.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="Scripts1/jquery-1.11.2.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
	var InterValObj; //timer变量，控制时间
	var count = 5; //间隔函数，1秒执行
	var curCount=60;//当前剩余秒数	
	
  $("#btnSendCode").click(function(){
	var phone=document.getElementById("username").value; 
	var _code = document.getElementById('code').value;
	if (!phone.match(/^(((1[3|4|5|7|8][0-9]{1}))+\d{8})$/)) {
		alert("手机号不正确");
		document.getElementById('username').focus();
		return;
	}
	var password=document.getElementById("password").value; 
	if(password==''){
		alert("请输入密码");
		document.getElementById('password').focus();
		return;		
	}
	if(_code==''){
		alert("请输入验证码");
		document.getElementById('code').focus();
		return;		
	}	
    var ifrm = document.getElementsByName('iframe')[0];  
    ifrm = document.getElementById('iframe');  
    ifrm.src = 'reg_yzm.php?phone='+phone+'&code='+_code;
	$("#btnSendCode").attr("disabled", "true");
	$("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
	InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次	
  });
 //timer处理函数
function SetRemainTime() {
            if (curCount == 0) {                
                window.clearInterval(InterValObj);//停止计时器
                $("#btnSendCode").removeAttr("disabled");//启用按钮
                $("#btnSendCode").val("重新发送验证码");
				curCount=60;
            }
            else {
                curCount--;
                $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
            }
        }
});		
</script> 
<body>
 <script>
function isWeiXin(){
    var ua = window.navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i) == 'micromessenger'){
        return true;
    }else{
        return false;
    }
}
$(document).ready(function(){
var openid = $("#openid").val();
$.ajax({
    type : "get",
    url : "http://m.zjkjgjt.com/user/api/check_login_callback.html",
    dataType : "jsonp",
    jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
    jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
    success : function(result){
	  if(result.status==1){
	  errShow('请将本页面分享给好友注册吧~', 1);
	  }else{ 
	      if(isWeiXin() && openid==''){
	          window.location.href ="http://m.zjkjgjt.com/user/login/weixin_reg/iuid-263978";
	      }  
	  }
    },
});
}); 
</script>
<div id="bd">
	<link rel="stylesheet" href="Css1/hi.css" /> 
	<style>
	.project-list > li > .prj-card > .circle > img{
	width: 60px;
    height: 60px;
	border-radius:36px;
	top:70%;
	left:-30px;
	}
	</style>
<div class="container">
	<div class="banner img-wrap">
		<img src="Picture1/banner_hi_v2.jpg" alt="" />
		<div class="banner-friend">
			<p class="big-text"><?php echo $nick ?></p>
			<p>加入分享赚以来我赚了不少，收益高，提现快！</p>
		</div>
	</div>
	<div class="superiority">
		<h2 class="title-hi">什么是分享赚？</h2>
		<p class="title-des">分享赚是一个将文章分享到朋友圈就可以获得收入的平台 <span class="media320">详情查看下方的视频哦！</span></p>
		<div>
<script type="text/javascript"> var letvcloud_player_conf =  {"uu":"bdsiz4hnfj","vu":"7d3cc6b8c3","auto_play":0,"gpcflag":1,"width":334,"height":255};</script>
<script type="text/javascript" src="Scripts1/bcloud.js"></script>
		</div>
	</div>
	<div class="superiority">
		<h2 class="title-hi">我为什么推荐分享赚？</h2>
		<p class="title-des">文章更新快，收入最高 <span class="media320">累计支付给会员超2000万元</span></p>
		<div>
			<ul class="super-list clearfix">
				<li class="one">
					<p>阅读单价高</p>
				</li>
				<li class="two">
					<p>提现一天到账</p>
				</li>
				<li class="three">
					<p>注册即送一元</p>
				</li>
			</ul>
		</div>
	</div>

	<div class="register" id="goReg">
		<h2 class="title-hi">注册后开始赚钱</h2>
		<p class="title-des">将人脉变成钱脉</p>
		<form action="reg.php"  method="post" class="form-register" name="form1" novalidate>
        <input type="hidden" value="<?php echo $_GET['uid']?>" name="tj_id">
			<ul class="form-list">
				<li>
					<div class="input-wrap">
						<div class="icon icon-phone"></div>
						<div class="inpu">
							<input type="tel" name="username" id="phone" class="wide-line" placeholder="请输入手机号" maxlength="11" >
						</div>
					</div>
				</li>
				<li>
					<div class="input-wrap">
						<div class="icon icon-key"></div>
						<div class="inpu">
							<input type="password" class="wide-line" id="password" name="password" placeholder="密码:请输入6位或以上的字符" />
							<span class="eye"></span>
						</div>
					</div>
				</li>
	 	<?php
			if($config['yunpian']!==''){
			?>
     <li class="clearfix">
					<div class="input-wrap wrap-min">
						<div class="icon icon-safe"></div>
						<div class="inpu">
							<input type="tel" id="SMSCode" name="yzm" class="code wide-line" maxlength="6" placeholder="请输入短信验证码" required="">
						</div>
					</div>
					<div class="verify">
							<input type="button" id="btnSendCode" onClick="btnSendCode()" name="btnSendCode" class="btn btn-red b" value="获取验证码"> 
					</div>
				</li>
     	<?php }?>
			</ul>			
			<div class="btn-wrap">
	 
 
			<button type="button" class="btn btn-red" id="btn-next" onClick="send();">注册去赚钱</button>	
			
			</div>
			<div class="btn-wrap">
			<a  class="btn download" href="/login.php">已有帐号,去登录</a>
			</div>
		</form>
	</div>
	<div class="project">
		<h2 class="title-hi">他们赚了多少钱？</h2>
		<p class="title-des">一边分享一边叫上好友一起玩能赚更多！</p>
		<ul class="project-list">
<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="Picture1/8ab4847bac7e43aeb770b68f45440fc4.gif" onerror="javascript:this.src='/upload/headimg/30.jpg';">
					</div>
					<h4>管理大号</h4>
					<p class="rate">赚了 37874元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="" onerror="javascript:this.src='/upload/headimg/3.jpg';">
					</div>
					<h4>快乐宝贝</h4>
					<p class="rate">赚了 19500元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="Picture1/8ec56f5db3d146bd957b6d62796ae8bd.gif" onerror="javascript:this.src='/upload/headimg/17.jpg';">
					</div>
					<h4>大号</h4>
					<p class="rate">赚了 19489元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="" onerror="javascript:this.src='/upload/headimg/13.jpg';">
					</div>
					<h4>180****8550</h4>
					<p class="rate">赚了 18938元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="Picture1/9d5db0237d14465cad6582ba51f3b33c.gif" onerror="javascript:this.src='/upload/headimg/8.jpg';">
					</div>
					<h4>心如止水</h4>
					<p class="rate">赚了 15648元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="Picture1/059812509a25409dbf1c953e77075630.gif" onerror="javascript:this.src='/upload/headimg/30.jpg';">
					</div>
					<h4>宋超</h4>
					<p class="rate">赚了 15317元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="Picture1/fd0f68007f3345e78463a70c624aac1c.gif" onerror="javascript:this.src='/upload/headimg/1.jpg';">
					</div>
					<h4>✎﹏ℳ๓₯㎕ζ雨ั 天</h4>
					<p class="rate">赚了 13976元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="Picture1/3de09eeb9acf403889e7376eefb18235.gif" onerror="javascript:this.src='/upload/headimg/21.jpg';">
					</div>
					<h4>小天使</h4>
					<p class="rate">赚了 12916元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="" onerror="javascript:this.src='/upload/headimg/28.jpg';">
					</div>
					<h4>亦贤</h4>
					<p class="rate">赚了 12576元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			<li class="clearfix">
				<div class="prj-card">
					<div class="circle">
						<img src="" onerror="javascript:this.src='/upload/headimg/13.jpg';">
					</div>
					<h4>潘氏</h4>
					<p class="rate">赚了 12071元</p>
					<div class="btn-wrap">
						
					</div>
				</div>
			</li>
			  
		</ul>
	</div>
</div>

<div class="pop pop1" style="display: none;">
    <p class="error">
        <br />
    </p>
</div>
<style>
  .geetest {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }
  .bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: gray;
    opacity: 0.7;
  }
  .wrap {
    width: 300px;
    margin: 10px auto;
    text-align: center;
    background-color: #fff;
    z-index: 2;
    position: relative;
  }
  .gt_wrapper {
    margin: 0 auto;
  }
  .wrap .top {
    padding: 0 8px;
    height: 44px;
    z-index: 1;
    position: relative;
    text-align: center;
    font-weight: 500;
  }

  .wrap .title {
    line-height: 45px;
    width: 200px;
    margin: 0 auto;
  }

  .exit {
    background-image: url('Images1/return.png');
    -moz-background-size: 12px auto;
    -o-background-size: 12px auto;
    -webkit-background-size: 12px auto;
    background-size: 12px auto;
    width: 12px;
    height: 22px;
    display: inline-block;
    vertical-align: middle;
    position: absolute;
    left: 8px;
    top: 11px;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    z-index: 10;
  }
  .exit:active {
    background-image: url('Images1/return_hover.png');
  }
</style>
  <div class="geetest" id="codebox">
    <div class="bg"></div>
    <div class="wrap">
      <div class="top">
        <a class="exit" id="close" href="javascript:;"></a>
        <div class="title">
          请通过验证
        </div>
      </div>
      <script type="text/javascript" src="Scripts1/get.js" async></script>
    </div>

  </div>
  <script>
    var qs = function(e) {
      return document.querySelector(e);
    };
     var button = document.getElementById("btnSendCode");

    var geetest = qs(".geetest");
    button.onclick = function() {
      geetest.style.display = "block";
    };
    var close = document.getElementById("close");
    close.onclick = function() {
      geetest.style.display = "none";
    };
    qs(".bg").onclick = function() {
      geetest.style.display = "none";
    };
    window.gt_custom_ajax = function(result, id, message) {
      if(result) {
        qs('#' + id).parentNode.parentNode.style.display = "none";
	var InterValObj; //timer变量，控制时间  
	var count = 60; //间隔函数，1秒执行  
	var curCount;//当前剩余秒数  
		curCount = count;
		var phone    = $("#phone").val();
		var pass     = $("#password").val();
		var par      = $("#par").val();
		var openid=$("#openid").val();
		var nicename=$("#nicename").val();
		var avatar=$("#avatar").val();
		var checkCode=$("#checkCode").val();
		var SMSCode=$("#SMSCode").val();
    value = $('#' + id).find('input');
    var data = {"geetest_challenge":value[0].value,"geetest_validate":value[1].value,"geetest_seccode":value[2].value,"phone":phone}
	if (phone != "") {
		if (!phone.match(/^(((1[3|4|5|7|8][0-9]{1}))+\d{8})$/)) {
			errShow("手机号不正确", 1);
			GeeTest[0].refresh();
		}
$.ajax({
    type : "get",
    url : "http://m.zjkjgjt.com/user/login/check_data_jsonp/",
    dataType : "jsonp",
	data:{data:JSON.stringify(data)},
    jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
    jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
    success : function(result){
	  if(result.status==0){
	  errShow(result.message, 1);
	  GeeTest[0].refresh();
	  }else{
				var time = 60;
				function timeCountDown(){
					if(time==0){
						clearInterval(timer);
						$("#btnSendCode").removeAttr("disabled");//启用按钮  
						$("#btnSendCode").val("重新发送");
						sends.checked = 1;
						return true;
					}
					$('#btnSendCode').val(time+"秒后重试");
					time--;
					return false;
					sends.checked = 0;
				}
				$("#btnSendCode").attr("disabled", "true");
				timeCountDown();
				var timer = setInterval(timeCountDown,1000);
				//InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次  
                 errShow(result.message, 1);
				GeeTest[0].refresh();
			  }
    },
    error:function(){
         alert('网络错误！请刷新重试！');
    }
});
	} else {
			errShow("手机号不能为空！", 1);
			GeeTest[0].refresh();
		}
      }
    }
  </script>

<script type="text/javascript">
	$('.eye').on('click', function(e){
		if($('#password').val()){
			$(this).toggleClass('open');
			$('#password').attr('type', $(this).hasClass('open') ? 'text' : 'password');
		}
	});	

	//提示窗口
	function errShow(content){
		$('.error').html(content);
		$('.pop1').show();
		setTimeout("errHide()",3000);
	}
	
	//隐藏错误提示
	function errHide(){
		$('.pop1').hide();
		$('.error').text('');
		$("#error").html('');
		;
	}
	
	//登陆提示
	function loginShow(content){
		$('.error').html(content);
		$('.pop1').show();
	}
	
 $("#btnSendCode").click(function(){
	var phone=document.getElementById("username").value; 
	var _code = document.getElementById('code').value;
	if (!phone.match(/^(((1[3|4|5|7|8][0-9]{1}))+\d{8})$/)) {
		alert("手机号不正确");
		document.getElementById('username').focus();
		return;
	}
	var password=document.getElementById("password").value; 
	if(password==''){
		alert("请输入密码");
		document.getElementById('password').focus();
		return;		
	}
	if(_code==''){
		alert("请输入验证码");
		document.getElementById('code').focus();
		return;		
	}	
    var ifrm = document.getElementsByName('iframe')[0];  
    ifrm = document.getElementById('iframe');  
    ifrm.src = 'reg_yzm.php?phone='+phone+'&code='+_code;
	$("#btnSendCode").attr("disabled", "true");
	$("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
	InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次	
  });
	

	//timer处理函数  
	function SetRemainTime() {
	var InterValObj; //timer变量，控制时间  
	var count = 60; //间隔函数，1秒执行  
	var curCount;//当前剩余秒数  
		curCount = count;
		if (curCount == 0) {
			window.clearInterval(InterValObj);//停止计时器  
			$("#btnSendCode").removeAttr("disabled");//启用按钮  
			$("#btnSendCode").val("重新发送验证码");
			code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效      
		} else {
			curCount--;
			$("#btnSendCode").val(curCount + "秒后重新获取");
		}
	}
	function send() {
		var phone    = $("#phone").val();
		var pass     = $("#password").val();
		var par      = $("#par").val();
		var openid=$("#openid").val();
		var nicename=$("#nicename").val();
		var avatar=$("#avatar").val();
		var checkCode=$("#checkCode").val();
		var SMSCode=$("#SMSCode").val();
		if(phone==''){
			errShow("手机号不能为空！", 1);
		}else if(!phone.match(/^(((1[3|4|5|7|8][0-9]{1}))+\d{8})$/)){
			errShow("手机号不正确！", 1);
		}else if(pass==''){
			errShow("密码不能为空！", 1);
  
		}else{
			
			 document.form1.submit();
			}
	}
</script>
</body>
</html>